package com.yida.gwj.api.factory;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yida.common.core.domain.R;
import com.yida.gwj.api.domain.*;
import com.yida.gwj.api.service.RemoteGwjConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 公维金服务降级处理
 *
 * @author hmh
 */
@Component
public class RemoteGwjConfigFallbackFactory implements FallbackFactory<RemoteGwjConfigService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteGwjConfigFallbackFactory.class);

    @Override
    public RemoteGwjConfigService create(Throwable throwable) {
        log.error("公维金配置服务调用失败:{}", throwable.getMessage());
        return new RemoteGwjConfigService() {
            @Override
            public R<GwjConfBusinessFlag> selectGwjConfBusinessFlagByBizFlagId(Integer bizFlagId, String source) {
                return R.fail("根据业务标识ID查询业务标识:{}" + throwable.getMessage());
            }

            @Override
            public R<List<String>> selectGwjConfStepConfigInfoCodeListByBizFlagId(Long stepId, String source) {
                return R.fail("根据业务标识ID查询业务步骤配置信息:{}" + throwable.getMessage());
            }

            @Override
            public R<List<GwjConfStep>> selectGwjConfStepListByFlagId(Integer flagId, String source) {
                return R.fail("根据业务标识查询步骤ID列表:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjConfStep> selectNextGwjConfStepByFlagId(Integer flagId, Long currentStep, String source) {
                return R.fail("查询下一个步骤:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjConfStep> selectPreviousGwjConfStepByFlagId(Integer flagId, Long currentStep, String source) {
                return R.fail("查询上一个步骤:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjConfCalculateData> selectCalculateDataByCalculateTypeIdAndAreaIdAndBuildTypeId(Long calculateTypeId, Long areaId, Integer buildTypeId, String source) {
                return R.fail("根据标准类型ID、地区ID、楼栋类型查询计算标准值数据:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjConfCalculateType> selectGwjConfCalculateTypeByCalculateTypeId(Long calculateTypeId, String source) {
                return R.fail("根据标准类型ID获取计算标准详细信息:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjConfDictData> getGwjConfDictDataByDictLabel(String dictLabel, String source) {
                return R.fail("根据字典标签查询字典项:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjConfStep> getFinalStep(Integer flagId, String source) {
                return R.fail("根据业务标识查询最后一个步骤:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjConfStep> getFirstStep(Integer flagId, String source) {
                return R.fail("根据业务标识查询第一个步骤:{}" + throwable.getMessage());
            }

            @Override
            public R<List<GwjConfBusinessFlag>> selectConfBusinessFlagList(GwjConfBusinessFlag confBusinessFlag, String source) {
                return R.fail("获取业务标识查询列表:{}" + throwable.getMessage());
            }

            @Override
            public R<List<GwjConfStep>> selectConfStepList(GwjConfStep confStep, String source) {
                return R.fail("获取步骤信息查询列表:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjBaseBusinessNum> getNextNum(Long areaId, Integer bizFlagId, String source) {
                return R.fail("获取下一步业务编号异常:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjConfStep> selectByConfStepId(Long stepId, String source) {
                return R.fail("获取当前步骤信息异常:{}" + throwable.getMessage());
            }

            public R<Integer> banUp(String serverIdentification, String outServerIdentification, String source) {
                return R.fail("修改附件状态为不可上传:{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> allowUp(String serverIdentification, String outServerIdentification, String source) {
                return R.fail("修改附件状态为可上传:{}" + throwable.getMessage());
            }

            @Override
            public R<String> innerGetConfigKey(String configKey, String source) {
                return R.fail("根据参数键名查询参数值:{}" + throwable.getMessage());
            }

            @Override
            public R innerEditGwjConfig(String configKey, String configValue, String source) {
                return R.fail("根据参数键名修改参数值:{}" + throwable.getMessage());
            }

            @Override
            public R<JSONObject> checkNextStepFinish(Integer flagId, Long stepId, String source) {
                return R.fail("检测当前下一步骤是否完结:{}" + throwable.getMessage());
            }

            @Override
            public R<JSONArray> getGwjConfStepConfigListInner(Long stepId, String source) {
                return R.fail("获取步骤配置信息失败！" + throwable.getMessage());
            }

            @Override
            public R<JSONObject> selectGwjConfBusinessFlagInfoByBizFlagId(Integer bizFlagId, String source) {
                return R.fail("获取步骤配置信息数据失败！" + throwable.getMessage());
            }

        };
    }

}
